package com.springboot.controller.images;

import com.springboot.pojo.Images;
import com.springboot.service.Images.ImagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/postman/images")
public class ImagesController {
    private ImagesService imagesService;

    @Autowired
    public ImagesController(ImagesService imagesService) {
        this.imagesService = imagesService;
    }

    @GetMapping("/all")
    public List<Images> getAllImages() {
        return imagesService.getAllImages();
    }

    @GetMapping("/{imageId}")
    public Images getImageById(@PathVariable Long imageId) {
        return imagesService.getImageById(imageId);
    }

    @PostMapping("/add")
    public void addImage(@RequestBody Images image) {
        imagesService.addImage(image);
    }

    @PutMapping("/update")
    public void updateImage(@RequestBody Images image) {
        imagesService.updateImage(image);
    }

    @DeleteMapping("/delete/{imageId}")
    public void deleteImage(@PathVariable Long imageId) {
        imagesService.deleteImage(imageId);
    }
}